package com.shengyin.ec.model.dao.news;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.shengyin.ec.model.dao.BaseDaoImpl;
import com.shengyin.ec.model.entity.News;

@Repository("newsDao")
public class NewsDaoImpl extends BaseDaoImpl<News> implements NewsDao {

	@Override
	public void deleteAllNews(long[] ids) {
		News news=null;
		List<News> newsList=new ArrayList<News>(0);
		for(long id:ids)
		{
			news=super.get(id);
			newsList.add(news);
		}
		super.deleteAll(newsList);
	}

	@Override
	public void deleteNewsByAuthor(String newsAuthor) {
		
	}

	@Override
	public List<News> getNewsList() {
		return null;
	}

	@Override
	public void deleteSelectedNews(Long[] ids) {
		News news=null;
		List<News> newsList=new ArrayList<News>(0);
		for(long id:ids)
		{
			news=super.get(id);
			newsList.add(news);
		}
		super.deleteAll(newsList);
		
	}
	
	

	@Override
	public List<News> getNewsList(int offset, int pagesize) {
		// TODO Auto-generated method stub
		return super.findByPage("from News news", offset, pagesize);
	}

	@Override
	public Long getTotal() {
		return (Long) super.find("select count(*) from News")	.get(0);
	}

}
